from typing import Union
from fastapi import FastAPI
import uvicorn
import sys
import os


app = FastAPI()

@app.get("/user01/{user_id}")
def get_user01(user_id):
    print(user_id, type(user_id))
    return {"user_id": user_id}

@app.get("/user02/{user_id}")
def get_user02(user_id: int):
    print(user_id, type(user_id))
    return {"user_id": user_id}


if __name__ == '__main__':
    print(sys.argv)

    # 获取当前文件的完整路径
    file_path = __file__
    # 获取文件名
    file_name = os.path.basename(file_path)
    print(file_name)

    start_args = file_name.split(".py")[0] + ":app"

    uvicorn.run(start_args, host="127.0.0.1", port=8000, reload=True)